package com.mouse.hxsj.util;

import com.mouse.damo.micro.*;
import lombok.extern.slf4j.Slf4j;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

@Slf4j
public class CmdUtil {
    public static String executeCmd(String command) {
        log.info("Execute command : " + command);
        StringBuilder build = new StringBuilder();
        Runtime runtime = Runtime.getRuntime();
        try {
            Process process = runtime.exec("cmd /c " + command);
            BufferedReader br = new BufferedReader(new InputStreamReader(process.getInputStream(), "UTF-8"));
            String line = null;
            while ((line = br.readLine()) != null) {
                log.info(line);
                build.append(line);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
        return build.toString();
    }

    public static void main(String[] args) throws Exception {
        String str = "D:\\腾讯游戏\\qq幻想世界\\qqhxsj.exe";
        System.out.println(executeCmd(str));
    }

    public static void followLeader(Com com) {
        Mouse mouse = new Mouse(com);
        FindStr findStr = new FindStr(com);
        new Window(com).clientToScreen(com.getHwnd());
        mouse.mouseClick(60, 50, false);
        Sleep.sleep(200);
        int[] duizhang = findStr.findStrE(0, 0, 1000, 800,
                "跟随队长", "ffffff", 0.9, 3);
        if (duizhang[0] != -1) {
            mouse.mouseClick(duizhang[1] + 5, duizhang[2], true);
        }

    }
}
